﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.Windows.Forms;
using System.IO;
using System.ComponentModel;
using System.Xml.Serialization;

namespace BDSim
{
    /// <summary>
    /// 环境段
    /// </summary>
    public class EnvironmentSegment : SegmentBase
    {
        #region 字段和属性
        /// <summary>
        /// 环境段中的模型列表
        /// </summary>
        private ObservableCollection<EnvBaseModel> _EnvModelList = new ObservableCollection<EnvBaseModel>();
        [Browsable(false)]
        public ObservableCollection<EnvBaseModel> EnvModelList
        {
            get { return _EnvModelList; }
            set { _EnvModelList = value; NotifyPropertyChanged("EnvModelList"); }
        }

        /// <summary>
        /// 当前路劲
        /// </summary>
        private string currentDirectory = Directory.GetCurrentDirectory();

        #endregion

        #region 构造函数
        /// <summary>
        /// 构造函数
        /// </summary>
        public EnvironmentSegment()
        {
            Type = ESegmentType.EnvironmentSegment;
            Name = "环境段";
            //创建保存数据文件路径及文件            
            string defaultenvpath = currentDirectory + "\\DataRecords\\环境段\\";
            if (!Directory.Exists(defaultenvpath))
            {
                Directory.CreateDirectory(defaultenvpath);
            }
        }
        #endregion

        #region 方法
        /// <summary>
        /// 初始化函数
        /// </summary>
        public override void Init()
        {            
            //父类初始化
            base.Init();
            //子模型初始化(空间环境、地理环境)
            EnvModelList[0].Init();
            EnvModelList[2].Init();
            //创建保存数据文件路径及文件            
            string defaultenvpath = currentDirectory + "\\DataRecords\\环境段\\";
            if (!Directory.Exists(defaultenvpath))
            {
                Directory.CreateDirectory(defaultenvpath);
            }
        }

        /// <summary>
        /// 环境段预初始化（天文环境），主要是读行星历表、极移跳秒EOP文件
        /// </summary>
        public void PreInit()
        {
            EnvModelList[1].Init();           
        }

        #endregion
    }
}
